{% extends "base.html" %}

{% block title %}用户登录{% endblock %}

{% block content %}
<div class="d-flex justify-content-center align-items-center" style="min-height: 80vh; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);">
    <div class="card shadow" style="width: 400px; border-radius: 15px; border: none;">
        <div class="card-header text-center py-4" style="background: #007bff; border-radius: 15px 15px 0 0;">
            <h3 class="text-white mb-0">用户登录</h3>
        </div>
        <div class="card-body p-4">
            <form method="post" class="needs-validation" novalidate>
                {% csrf_token %}
                <div class="mb-4">
                    <div class="input-group">
                        <span class="input-group-text bg-light border-0">
                            <i class="fas fa-user text-primary"></i>
                        </span>
                        <input type="text" class="form-control border-0 bg-light ps-2" 
                               id="username" name="username" placeholder="请输入用户名" required
                               style="border-radius: 0 8px 8px 0;">
                    </div>
                </div>
                <div class="mb-4">
                    <div class="input-group">
                        <span class="input-group-text bg-light border-0">
                            <i class="fas fa-lock text-primary"></i>
                        </span>
                        <input type="password" class="form-control border-0 bg-light ps-2" 
                               id="password" name="password" placeholder="请输入密码" required
                               style="border-radius: 0 8px 8px 0;">
                    </div>
                </div>
                <button type="submit" class="btn btn-primary w-100 py-2 mb-3" 
                        style="border-radius: 8px; font-size: 1.1rem;">
                    登录
                </button>
                <div class="text-center">
                    <span class="text-muted">还没有账号？</span>
                    <a href="{% url 'users:register' %}" class="text-primary text-decoration-none">立即注册</a>
                </div>
            </form>
        </div>
    </div>
</div>

<style>
.input-group-text {
    border-radius: 8px 0 0 8px;
}

.form-control:focus {
    box-shadow: none;
    border-color: #007bff;
}

.btn-primary {
    background: #007bff;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
}
</style>

{% if form.errors %}
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
    <div class="toast show bg-danger text-white" role="alert">
        <div class="toast-header bg-danger text-white">
            <i class="fas fa-exclamation-circle me-2"></i>
            <strong class="me-auto">登录失败</strong>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast"></button>
        </div>
        <div class="toast-body">
            用户名或密码错误，请重试。
        </div>
    </div>
</div>
{% endif %}
{% endblock %}
